﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/Admin.Master" AutoEventWireup="true" CodeBehind="MyPhotoSets.aspx.cs" Inherits="JohnnySins.Admin.MyPhotoSets" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <link href="<%=ResolveClientUrl("~") %>Styles/fileuploader.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="<%=ResolveClientUrl("~") %>Scripts/fileuploader.min.js"></script>
    <script type="text/javascript">
      $(function () {
         $("#editDialog").dialog({ modal: true, autoOpen: false, width: 900, resizable: false });
         $("#editDialog").parent().appendTo(jQuery("form:first"));
         $(".ui-dialog-titlebar").hide();
         $("#ui-datepicker-div").css("z-index", "9999");

         Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(function (evt, args) {
            $.datepicker.setDefaults($.datepicker.regional[""]);
            $("#<%= txtPhotoSetDate.ClientID %>").datepicker($.datepicker.regional["en-GB"]);

            $("#<%= txtPhotoSetDate.ClientID %>").datepicker({
               showmonth: true,
               autoSize: true,
               showAnim: 'slideDown',
               duration: 'fast'
            });

            $("#btnShowDate").click(function () {
                $("#<%= txtPhotoSetDate.ClientID %>").datepicker('show');
            });

            var button = $('#fu1')[0];
            uploader = new qq.FileUploader({
              element: button,
              sizeLimit: 0, // max size
              action: 'FileUpload.aspx',
              multiple: true,
              /*async: false,*/
              uploadButtonText: 'Add Photos',
              cancelButtonText: 'Delete',
              autoUpload: false,
              debug: true,
              /*params: { photoSetId: 0 },*/
              onComplete: 
                function (id, fileName, responseJSON) { __doPostBack('upDetails', $('#<%= hdId.ClientID %>').text()); },
              onUpload: function (id, fileName) {   },
              onProgress: function (id, fileName, uploadedBytes, totalBytes) {  },
              onSubmit: function (id, fileName) { uploader.setParams({ photoSetId: $('#<%= hdId.ClientID %>').text() }); },
              onCancel: function (id, fileName) {  }
            });
            
         });

         <%=this.JsCodeToRunOnReady%>;
      });

      function createUpdateForm(id) {
         __doPostBack('upDetails', id);
      }

      function SetFlagValue(id, value, flagId)
      {
        var valueInt = value?1:0;
        $.ajax({
            type: "POST",
            url: "MyPhotoSets.aspx/SetFlagValue",
            data: "{'id' : " + id + ", 'value' : " + valueInt + ", 'flagId' : " + flagId + "}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(msg) {
            },
            error: function () {
                   alert('An Error has occured');
            }
        });
      }


    </script>
    <style type="text/css">
        .photosets_thumb_features{
        	margin:5px;
        }
        .photosets_thumb{
    	    position:relative;
	        display:block;
        }
        .photosets_thumb img{
	        border-radius:10px;
		    -moz-border-radius:10px;
		    -webkit-border-radius:10px;
		    -o-border-radius:10px;
		    -ms-border-radius:10px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div class="page_title">
        <h1>My Photosets</h1>                		
    </div>
                    
    <!--start tabel conetnt-->
    <div class="admin_table_container">
        <h3>Starring Photos</h3>

        <asp:UpdatePanel ID="upPhotoSet" runat="server" UpdateMode="Conditional">
         <ContentTemplate>
            <div class="table-responsive">
               <asp:GridView ID="grid" AutoGenerateColumns="false" runat="server" CssClass="table table-bordered table-hover"
                  AllowPaging="False" PageSize="20" OnRowDataBound="grid_RowDataBound" OnRowCommand="grid_Command">
                  <PagerSettings Mode="Numeric" PageButtonCount="4" NextPageText=">" PreviousPageText="<"
                     FirstPageText="<<" LastPageText=">>" />
                  <Columns>
                     <asp:TemplateField>
                        <HeaderTemplate>
                           <asp:CheckBox ID="chbAll" runat="server" AutoPostBack="true" OnCheckedChanged="chbAll_CheckChanged" />
                        </HeaderTemplate>
                        <ItemTemplate>
                           <asp:HiddenField ID="hidId" Value='<%#Eval("PhotoSetId")%>' runat="server" />
                           <asp:CheckBox runat="server" Checked='<%#Eval("Selected")%>' ID="cbSelected" />
                        </ItemTemplate>
                     </asp:TemplateField>
                     <asp:TemplateField HeaderText="Title/Description">
                        <ItemTemplate>
                           <asp:Label ID="lblPhotoSetTitle" Text='<%# Eval("PhotoSetTitle") %>' runat="server" />
                        </ItemTemplate>
                     </asp:TemplateField>
                     <asp:TemplateField HeaderText="Photos">
                        <ItemTemplate>
                           <asp:Label ID="lblPhotoFiles" Text='<%# Eval("PhotoFiles") %>'
                              runat="server" />
                        </ItemTemplate>
                     </asp:TemplateField>
                     <asp:TemplateField HeaderText="Status">
                        <ItemTemplate>
                           <asp:Label ID="lblStatus" Text='<%# Eval("Status") %>' runat="server" />
                        </ItemTemplate>
                     </asp:TemplateField>
                     <asp:TemplateField HeaderText="Action">
                        <ItemTemplate>
                           <a href='javascript:void(0)' onclick="javascript:createUpdateForm(<%#Eval("PhotoSetId")%>);">
                              <img src="<%=ResolveClientUrl("~") %>images/admin/action_icon/edit_icon.png" alt="" title="Edit"
                                 border="0" />
                           </a>
                           <asp:ImageButton runat="server" ImageUrl="~/images/admin/action_icon/delete_icon.gif" ToolTip="Delete"
                              Style="vertical-align: middle;" ID="lbtnDelete" OnCommand="grid_Command" CommandName="delete"
                              CommandArgument='<%# Eval("PhotoSetId")%>' OnClientClick="return confirm('Please confirm if you want to delete scene')" />
                           <a href="#"><img border="0" title="Preview" alt="cancle" src="<%=ResolveClientUrl("~") %>images/admin/action_icon/preview_icon.png"></a>
                           <asp:ImageButton ID="btnDeactivate" OnCommand="grid_Command" ToolTip="Deactivate"
                              Style="vertical-align: middle;" CommandName="deactivate" CommandArgument='<%# Eval("PhotoSetId")%>'
                              runat="server" OnClientClick="return confirm('Please confirm if you want to deactivate scene')"
                              ImageUrl="~/images/admin/action_icon/deactive.png" />
                           <asp:ImageButton ID="btnActivate" OnCommand="grid_Command" ToolTip="Activate" Style="vertical-align: middle;"
                              CommandName="activate" CommandArgument='<%# Eval("PhotoSetId")%>' runat="server"
                              OnClientClick="return confirm('Please confirm if you want to activate scene')"
                              ImageUrl="~/images/admin/action_icon/logout.png" />
                        </ItemTemplate>
                     </asp:TemplateField>
                  </Columns>
               </asp:GridView>
            </div>
         </ContentTemplate>
      </asp:UpdatePanel>

                        
        <div class="button_group">
        <div class="row">
            <div class="col-sm-6 col-lg-5">
                                    <asp:Button CssClass="btn btn-default" ID="btnDeleteSelected" OnClientClick="return confirm('Please confirm if you want to delete selected videos')"
                                        Text="Delete Selected" runat="server" OnClick="btnDeleteSelected_Click" />
                                    <asp:Button CssClass="btn btn-default" ID="btnActivateSelected" OnClientClick="return confirm('Please confirm if you want to activate selected videos')"
                                        Text="Activate Selected" runat="server" OnClick="btnActivateSelected_Click" />
                                    <asp:Button CssClass="btn btn-default" ID="btnDeactivateSelected" OnClientClick="return confirm('Please confirm if you want to deactivate selected videos')"
                                        Text="Deactivate Selected" runat="server" OnClick="btnDeactivateSelected_Click" />
                                    
            </div>
            <div class="col-sm-6 col-lg-7">
                                    <asp:Button CssClass="btn btn-default" ID="btnReverseSelected" Text="Reverse Selected"
                                        runat="server" OnClick="btnReverseSelected_Click" />
                                    <asp:Button CssClass="btn btn-default" ID="btnUploadNew" Text="Upload New"
                                        runat="server" OnClientClick="createUpdateForm(-1); return false;" />
            </div>
        </div>                            	
      </div>


    </div>
    <!--end tabel scenes conetnt-->

    <div id="editDialog">
      <asp:UpdatePanel runat="server" ID="upDetails" OnLoad="upDetails_Load" UpdateMode="Conditional"
         ClientIDMode="Static">
         <ContentTemplate>
            <div class="row">
               <div class="fieldset_block col-lg-12 page_area">
                  <fieldset>
                     <legend>
                        <h4>
                           <asp:Label runat="server" ID="lblDialogTitle"></asp:Label>
                        </h4>
                     </legend>
                     <asp:Label runat="server" ID="hdId" Style="display: none;" />
                     
                     <div class="col-sm-6 col-md-6 col-lg-6">
                     <div class="display_inputbox_panel">
                        <h4>Photosets Information</h4>
                        <div class="display_inputbox_content">
                                    	<div class="form-group">
                                            <label for="inputname" class="col-sm-4 col-md-3 control-label custom_label">Title:</label>
                                            <div class="col-sm-8 col-md-9">
                                                <asp:TextBox CssClass="form-control" placeholder="Enter Photosets Title" ID="txtPhotoSetTitle"
                                                    ValidationGroup="newItem" runat="server" />
                                                <asp:RequiredFieldValidator ID="RequiredFieldValidator4" ControlToValidate="txtPhotoSetTitle"
                                                    runat="server" Text="*" ValidationGroup="newItem" ForeColor="Red" Display="Dynamic" />
                                            </div>
                                        </div>
                                        
                                        <div class="form-group">
                                            <label for="inputname" class="col-sm-4 col-md-3 control-label custom_label">Date:</label>
                                            <div class="col-sm-8 col-md-9">
                                                <div class="input-group">
                                                   <asp:TextBox ID="txtPhotoSetDate" CssClass="form-control" runat="server"></asp:TextBox>
                                                   <span class="input-group-btn">
                                                        <button class="btn btn-default" type="button" id="btnShowDate">
                                                            <img src="<%=ResolveClientUrl("~") %>images/admin/calander_icon.png" alt="calander" title="Calander" />
                                                        </button>
                                                   </span>
                                                </div><!-- /input-group -->
                                            </div>
                                        </div>
                                        
                                        <div class="form-group">
                                            <label for="inputname" class="col-sm-4 col-md-3 control-label custom_label">Starring:</label>
                                            <div class="col-sm-8 col-md-9">
                                                <asp:TextBox CssClass="form-control" placeholder="Starring Name" ID="txtPhotoStarring"
                                                    ValidationGroup="newItem" runat="server" />
                                            </div>
                                        </div>
                                        
                                        <div class="form-group">
                                            <label for="inputname" class="col-sm-4 col-md-3 control-label custom_label">Description:</label>
                                            <div class="col-sm-8 col-md-9">
                                                <asp:TextBox CssClass="form-control" ID="txtPhotoDescription" runat="server" TextMode="MultiLine"
                                                    Rows="5" ValidationGroup="newItem" />
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="checkbox_radio_text col-sm-6 col-md-6">
                                                <input type="checkbox" runat="server" id="chbIsMemberPS" name="chbIsMemberPS" />Member Page
                                            </label>
                                            <label class="checkbox_radio_text col-sm-6 col-md-6">
                                                <input type="checkbox" runat="server" id="chbIsPublicPS" name="chbIsPublicPS" />Public Page
                                            </label>
                                        </div>
                        </div>
                        <div class="button_group">
                           <asp:Button CssClass="btn btn-success" ID="btnSave" ValidationGroup="newItem" Text="Save" 
                              runat="server" OnClick="btnSave_Click" ClientIDMode="Static" />
                           <asp:Button CssClass="btn btn-info" ID="btnCancel" Text="Cancel" runat="server" OnClientClick="$('#editDialog').dialog('close'); __doPostBack('upPhotoSet', ''); return false;"
                              ClientIDMode="Static" />
                        </div>
                     </div>
                     </div>
                     <div class="col-sm-6 col-md-6 col-lg-6" runat="server" id="divFiles">
                        <div class="display_inputbox_panel">
                            <h4>Already uploaded</h4>
                            <div class="form-group" style="padding-top:10px;">
                                <asp:Repeater runat="server" ID="rptPhotos" OnItemDataBound="rptPhotos_ItemDataBound" OnItemCommand="rptPhotos_ItemCommand" >
                                    <ItemTemplate>
                                        <div class="col-lg-12 form-group">
                                            <div class="col-sm-6 col-md-6 col-lg-6">
                                                <div class="photosets_thumb">
                                                    <asp:Image runat="server" ID="imgPhoto" CssClass="img-responsive" style="max-height:85px;" />
                                                </div>
                                                <%# Eval("PhotoSetPhotoFileName")%>
                                            </div>
                                            <div class="col-sm-6 col-md-6 col-lg-6">
                                                <label class="checkbox_radio_text"><input type="checkbox" runat="server" id="chbIsMember" name="chbIsMember" checked='<%# Eval("IsMember")%>' />Member Page</label>
                                                <label class="checkbox_radio_text"><input type="checkbox" runat="server" id="chbIsPublic" name="chbIsPublic" checked='<%# Eval("IsPublic")%>'/>Public Page</label>
                                                <label class="checkbox_radio_text"><input type="checkbox" runat="server" id="chbIsMemberPoster" name="chbIsMemberPoster" checked='<%# Eval("IsMemberPoster")%>'/>Member Poster</label>
                                                <label class="checkbox_radio_text"><input type="checkbox" runat="server" id="chbIsPublicPoster" name="chbIsPublicPoster" checked='<%# Eval("IsPublicPoster")%>'/>Public Poster</label>
                                                <asp:ImageButton runat="server" ImageUrl="~/images/admin/action_icon/delete_icon.gif" ToolTip="Delete"
                                                                Style="vertical-align: middle;" ID="lbtnDeletePhoto" CommandName="deletePhoto"
                                                                CommandArgument='<%# Eval("PhotoSetId")+","+ Eval("PhotoSetPhotoId")%>' OnClientClick="return confirm('Please confirm if you want to delete photo')" />
                                            </div>
                                        </div>
                                    </ItemTemplate>
                                </asp:Repeater>
                            </div>
                            <h4>Newly upload</h4>
                            <div class="form-group" style="padding-left:15px;">
                                <div id="fu1" style="width:100%; margin-top: 5px; margin-bottom: 5px;"></div>
                                <button type="button" class="btn btn-success" id="btnUpload" onclick="uploader.uploadStoredFiles();">Upload</button>
                            </div>
                        </div>
                     </div>

                  </fieldset>
               </div>
            </div>
         </ContentTemplate>
         <Triggers>
            <asp:AsyncPostBackTrigger ControlID="btnSave" EventName="Click" />
         </Triggers>
      </asp:UpdatePanel>
   </div>

   <script type="text/javascript">
       $(function () {
           
       });
    </script>
</asp:Content>
